import { request, decodeURI } from '../utils'

export async function query (params) {
  if(params.keyword){
      const url = '/order/query?jsessionid=' + localStorage.getItem("token") + '&length=' + params.pageSize + '&offset=' + (params.current-1) + 
      '&field=' + params.field + '&keyword=' + params.keyword + "&orderStatus="+params.orderStatus;
      return request(url, {
        method: 'get',
        data: params
      })
  }else{
      const url = '/order/query?jsessionid=' + localStorage.getItem("token") + '&length=' + params.pageSize + '&offset=' + (params.current-1) +"&orderStatus="+params.orderStatus
      return request(url, {
        method: 'get',
        data: params
      })
  }
}
export async function edist(params){
  const url = '/order/updateOrderStatus/?jsessionid=' + localStorage.getItem("token")+ "&orderSerial=" +params.orderSerial +"&orderStatus=" +params.orderStatus
  return request(url, {
    method: 'PUT',
    data: params
  })
}

export async function serial(params){
  const url = '/order/get/'+params+'?jsessionid=' + localStorage.getItem("token")
  return request(url, {
    method: 'get',
    data: params
  })
}

export async function create (params) {
  const url = '/order/add/?jsessionid=' + localStorage.getItem("token")
  return request(url, {
    method: 'post',
    headers: {'Accept': 'application/json','Content-Type': 'application/json'},
    body: JSON.stringify(params)
  })
}





